package com.leyou.trade.web;

import com.leyou.trade.entity.CartItem;
import com.leyou.trade.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("cart")
@RestController
public class CartController {

    @Autowired
    private CartService cartService;

    /**
     *  新增购物车
     * @param cartItem 购物车数据
     * @return 无
     */
    @PostMapping
    public ResponseEntity<Void> saveCartImpl(@RequestBody CartItem cartItem){
        //新增到购物车
        cartService.saveCartItem(cartItem);

        return ResponseEntity.status(HttpStatus.CREATED).build();
    }

}
